load("//bazel:mongo_src_rules.bzl", "mongo_cc_library", "mongo_cc_unit_test")

package(default_visibility = ["//visibility:public"])

exports_files(
    [
        "measurement.h",
        "timeseries_write_ops.cpp",
        "timeseries_write_ops.h",
        "timeseries_write_ops_utils.cpp",
        "timeseries_write_ops_utils.h",
        "timeseries_write_ops_utils_internal.cpp",
        "timeseries_write_ops_utils_internal.h",
    ],
)

mongo_cc_library(
    name = "timeseries_write_ops",
    srcs = [
        "timeseries_write_ops.cpp",
    ],
    hdrs = [
        "timeseries_write_ops.h",
    ],
    no_undefined_ref_DO_NOT_USE = False,
    deps = [
        "timeseries_write_ops_utils_internal",
        "//src/mongo/db:commands",
        "//src/mongo/db:server_base",
        "//src/mongo/db:shard_role",
        "//src/mongo/db/catalog:collection_uuid_mismatch_info",
        "//src/mongo/db/catalog:document_validation",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/commands:mongod_fcv",
        "//src/mongo/db/query/write_ops:write_ops_exec_util",
        "//src/mongo/db/query/write_ops:write_ops_parsers",
        "//src/mongo/db/stats:counters",
        "//src/mongo/db/stats:server_read_concern_write_concern_metrics",
        "//src/mongo/db/timeseries:bucket_compression_failure",
        "//src/mongo/db/timeseries:timeseries_options",
        "//src/mongo/db/timeseries:timeseries_write_util",
        "//src/mongo/db/timeseries/bucket_catalog",
        "//src/mongo/db/transaction",
        "//src/mongo/db/update:update_common",
    ],
)

mongo_cc_library(
    name = "timeseries_write_ops_utils_internal",
    srcs = [
        "timeseries_write_ops_utils_internal.cpp",
        "timeseries_write_ops_utils_internal.h",
    ],
    hdrs = [
        "measurement.h",
        "//src/mongo/db/timeseries/bucket_catalog:bucket_catalog_helpers.h",
        "//src/mongo/db/timeseries/bucket_catalog:flat_bson.h",
        "//src/mongo/db/timeseries/bucket_catalog:write_batch.h",
        "//src/mongo/util/tracking",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:server_base",
        "//src/mongo/db/catalog:document_validation",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/commands:mongod_fcv",
        "//src/mongo/db/query/write_ops:write_ops_exec_util",
        "//src/mongo/db/query/write_ops:write_ops_parsers",
        "//src/mongo/db/stats:counters",
        "//src/mongo/db/storage:storage_options",
        "//src/mongo/db/timeseries:bucket_compression",
        "//src/mongo/db/timeseries:bucket_compression_failure",
        "//src/mongo/db/timeseries:timeseries_extended_range",
        "//src/mongo/db/timeseries:timeseries_options",
        "//src/mongo/db/timeseries/bucket_catalog",
    ],
)

mongo_cc_library(
    name = "timeseries_write_ops_utils",
    srcs = [
        "timeseries_write_ops_utils.cpp",
    ],
    hdrs = [
        "timeseries_write_ops_utils.h",
    ],
    deps = [
        "//src/mongo/db/query/write_ops:write_ops_parsers",
    ],
)

mongo_cc_unit_test(
    name = "db_timeseries_write_ops_test",
    srcs = [
        "timeseries_write_ops_test.cpp",
    ],
    tags = ["mongo_unittest_fourth_group"],
    deps = [
        "//src/mongo/db/catalog:catalog_test_fixture",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/query/write_ops:write_ops_exec",
        "//src/mongo/db/timeseries/write_ops:timeseries_write_ops",
        "//src/mongo/idl:server_parameter_test_util",
    ],
)
